<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: blog_startpage.php 135 2013-09-22 07:30:55Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 135 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:30:55 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright © since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	© 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	© 2002-2003 osCommerce - www.oscommerce.com
* 	© 2003     nextcommerce - www.nextcommerce.org
* 	© 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

if(!$browser->isMobile(USE_MOBILE_TEMPLATE)) {
	$module_smarty = new Smarty;
	$items = array();
	$module_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');

	$select_items = $db->db_query_limit("SELECT
											name, 
											description, 
											DATE_FORMAT(date, '%d.%m.%Y') AS date_formated, 
											allow_comment, 
											item_id, 
											lenght 
										FROM
											".TABLE_BLOG_ITEMS."
										WHERE
											status = '2'
										AND
											language_id = '".$_SESSION['languages_id']."'
										ORDER BY
											id DESC", BLOG_MAX_BLOG_ITEMS_START);

	while(!$select_items->EOF) { $cnt++;
		$items[$cnt] = array('name' => $select_items->fields['name'],
							'description' => truncate($select_items->fields['description'], $select_items->fields['lenght']),
							'date' => $select_items->fields['date_formated'],
							'blog_link' => href_link(FILENAME_BLOG, 'blog_cat='.$select_items->fields['categories_id'].'&blog_item='.$select_items->fields['item_id']));
	
		if($select_items->fields['allow_comment'] == '1') {
			$kommentare = $db->db_query("SELECT id FROM ".TABLE_BLOG_COMMENT." WHERE blog_id = '".$select_items->fields['item_id']."' ");
			$items[$cnt]['kommentare'] = $kommentare->_numOfRows;
		}			
		$select_items->MoveNext();
	}

	if (sizeof($items) >= 1) {
		$module_smarty->assign('language', $_SESSION['language']);
		$module_smarty->assign('blog_items', $items);
		$module_smarty->assign('more_link', MORE_INFO);

		$module = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/blog_startpage.html');

		$default_smarty->assign('MODULE_blog_startpage', $module);
	}
}